/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import stealth.Main;

/**
 *
 * @author Joshua
 */
public class HotKeyProvider extends GUIItem {

    private static int hotKeys = 0;
    private int keyMapped;
    private Runnable run;
    private boolean threaded;

    public HotKeyProvider(int key, Runnable action, boolean thread) {
        super("HKProvider " + hotKeys++);
        keyMapped = key;
        run = action;
        threaded = thread;
    }

    @Override
    public void reactToKeyEvents() {
        if (Main.game.keyDown(keyMapped)) {
            if (threaded) {
                new Thread(run).start();
            } else {
                run.run();
            }
        }
    }
}
